<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>合同管理</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript">     
			$(function(){ 
				var defHeight = 300,wh=$(window).height();
				var lh=$('.location').height(),fh=$('#floatHead').height(),sh=$('.det-list').height(),ph=$('.pagelist').height();
				defHeight = (wh-lh-fh-sh-ph-130);
				$('.flexgrid').flexigrid({striped:true,height:300});
			});
			
			function page(n,s){
				$("#pageNo").val(n);
				$("#pageSize").val(s);
				$("#searchForm").submit();
	        	return false;
	        }
	        
	        function deleteAll(){
				var ids =[];//定义一个数组    
	            $('input[name="checkall"]:checked').each(function(){    
	                ids.push($.trim($(this).val()));
	            });
	            document.location.href='${ctx}/qd/contract/delete?ids='+ids;
			}
		</script>
	</head>
	<body>
		<sys:message content="${message}"/>
		<c:set var="nowDate" value="<%=System.currentTimeMillis()%>"></c:set>
		<!--导航栏-->
		<div class="location">
			<a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
			<a href="${ctx}/center" class="home"><i></i>
			<span>首页</span></a> 
			<i class="arrow"></i> 
			<span>合同管理</span>
		</div>
		<!--/导航栏-->

		<!--工具栏-->
		<div id="floatHead" class="toolbar-wrap">
			<div class="toolbar">
				<div class="box-wrap">
					<a class="menu-btn"></a>
					<div class="l-list">
						<ul class="icon-list">
							<li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
							<shiro:hasPermission name="qd:contract:add"><li><a class="add" href="${ctx}/qd/contract/form"><i></i><span>新增合同</span></a></li></shiro:hasPermission>
						</ul>
					</div>
					<div class="r-list" style="display:none;">
						<input name="txtKeywords" type="text" id="txtKeywords" class="keyword" /> 
						<a id="lbtnSearch" class="btn-search" href="javascript:void(0)">查询</a>
					</div>
				</div>
			</div>
		</div>
		<!--/工具栏-->
		
		<!--搜索栏-->
		<form:form id="searchForm" modelAttribute="contract" action="${ctx}/qd/contract" method="post">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
			<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
			<div class="det-list clearfix">
			    <div class="group btm">
					<div class="control">
			            <div class="title">合同编号</div>
			            <form:input path="code" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">创建人</div>
			            <form:input path="createBy.name" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">会员姓名</div>
			            <form:input path="member.name" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">是否断号</div>
			            <div class="rule-single-select single-select">
								<form:select path="broken" htmlEscape="false" cssClass="input normal">
									<form:option label="请选择...." selected="selected" value="" />
									<form:option label ="未断号" value="0" />
									<form:option label ="断号" value="1" />
								</form:select>
							</div>
			        </div>
			    </div>
			    <br>
			    <div class="group btm">
			    	<div class="control">
			            <div class="title">会员手机号</div>
			            <form:input path="member.mobile" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">宝宝姓名</div>
			            <form:input path="student.name" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">所属顾问</div>
			            <form:input path="sales.name" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
					 <div class="title">合同状态</div>
					<div class="rule-single-select single-select">
								<form:select path="abort" htmlEscape="false" cssClass="input normal">
									<form:option label="请选择...." selected="selected" value="" />
									<form:option label ="正常" value="0" />
									<form:option label ="中止" value="1" />
								</form:select>
							</div>
					</div>
			    </div>
			    <br>
			    <div class="group btm">
			      <div class="control">
			    	<div class="title">当前合同</div>
			            <div class="rule-single-select single-select">
								<form:select path="status" htmlEscape="false" cssClass="input normal">
									<form:option label="请选择...." selected="selected" value="" />
									<form:option label ="是" value="0" />
									<form:option label ="否" value="1" />
								</form:select>
							</div>
					</div>
					<div class="control">
			            <div class="title">年龄段</div>
				            <div class="rule-single-select single-select">
										<form:select path="student.level" >
											<form:option value="" selected="selected" label="请选择" />
											<form:option value="L1"  label="L1" />
											<form:option value="L2"  label="L2" />
											<form:option value="L3"  label="L3" />
											<form:option value="L4"  label="L4" />
											<form:option value="L5"  label="L5" />
											<form:option value="L6"  label="L6" />
											<form:option value="L6+"  label="L6+" />
										</form:select>
							</div>
			        </div>
			        <div class="control">
			            <div class="title">有效日期</div>
			            <div class="date-input">
			            	<i></i>
			            	<fmt:formatDate value="${contract.startOn}" pattern="yyyy-MM-dd" var="startOn" />
			            	<form:input path="startOn"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" htmlEscape="false" cssClass="input" value="${startOn}" />&nbsp;&nbsp;&nbsp;~
			            </div>
			        </div>
			         <div class="date-input">
			            <i></i>
			            <fmt:formatDate value="${contract.endOn}" pattern="yyyy-MM-dd" var="endOn" />
			          	 <form:input path="endOn"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"  htmlEscape="false" cssClass="input" value="${endOn}" />
		          	 </div>
			    </div>
			    <br>
			    <div class="group btm">
			     <div class="control">
			            <div class="title">免费体验</div>
			            <div class="rule-single-select single-select">
								<form:select path="isFree" htmlEscape="false" cssClass="input normal">
									<form:option label="请选择...." selected="selected" value="" />
									<form:option label ="否" value="0" />
									<form:option label ="是" value="1" />
								</form:select>
							</div>
			        </div>	
			        <div class="control">
			            <div class="title">合同金额</div>
			            <form:input path="amount" htmlEscape="false" cssClass="input normal"/>
			        </div>
			        <div class="control">
			            <div class="title">创建日期</div>
			            <div class="date-input">
			            	<i></i>
			            	<fmt:formatDate value="${contract.createStart}" pattern="yyyy-MM-dd" var="createStart" />
			            	<form:input path="createStart"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" htmlEscape="false" cssClass="input" value="${createStart}" />&nbsp;&nbsp;&nbsp;~
			            </div>
			        </div>
			         <div class="date-input">
			            <i></i>
			            <fmt:formatDate value="${contract.createEnd}" pattern="yyyy-MM-dd" var="createEnd" />
			          	 <form:input path="createEnd"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"  htmlEscape="false" cssClass="input" value="${createEnd}" />
		          	 </div>
			    </div>
			    <br>
			    <div class="group btm">
			   		 <div class="control">
			            <div class="title">已付全款</div>
			            <div class="rule-single-select single-select">
								<form:select path="isFull" htmlEscape="false" cssClass="input normal">
									<form:option label="请选择...." selected="selected" value="" />
									<form:option label ="是" value="-2" />
									<form:option label ="否" value="-1" />
								</form:select>
							</div>
			        </div>	
			    </div>
			    <div class="group searchbtn">
			        <div class="btn-list">
			            <input type="submit" name="btnDetailedSearch" value="查询" id="btnDetailedSearch" class="btn">
			            <input name="btnReturn" type="reset" value="重置" class="btn yellow">
			        </div>
			    </div>
			    <div style="clear:both;"></div>
			</div>
		</form:form>
		<!--/搜索栏-->
		
		<!--列表-->
		<div class="table-container">
			<table class="flexgrid"  style="text-align : center;">
				<thead>
					<tr  >
						<th width="25" >选择</th>
						<th style="text-align: center;" width="160">操作</th>
						<th width="50" >已支付</th>
						<th width="100" >合同编号</th>
						<th width="50" >合同金额</th>
						<th width="80">合同金额有效期</th>
						<th width="50">状态</th>
						<th width="50">断号</th>
						<th width="50">当前合同</th>
						<th width="80">支付状态</th>
						<th width="50">会员</th>
						<th width="80">会员手机号</th>
						<th width="80">宝宝姓名</th>
						<th width="80">宝宝出生日期</th>
						<th width="80">所属顾问</th>
						<th width="80">创建人</th>
						<th width="80">创建日期</th>
						<th width="80">最后修改</th>
						<th width="80">修改日期</th>
						<th width="80">免费体验</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${page.list}" var="contract">
					<tr>
						<td style="text-align:center;">
							<span class="checkall" style="vertical-align: middle;">
								<input type="checkbox" name="checkall" value="${contract.id}" />
							</span> 
							<%-- <input type="hidden" name="checkall" value="${contract.id}" /> --%>
						</td>
						<td style="text-align: center">
						<shiro:hasPermission name="qd:addtran:add">
							<a href="${ctx}/qd/contract/addtransrecord?id=${contract.id}">新增支付</a>&nbsp;|&nbsp;
						</shiro:hasPermission>
						<shiro:hasPermission name="qd:contract:edit">
							<a href="${ctx}/qd/contract/form?id=${contract.id}">修改</a>&nbsp;|&nbsp;
						</shiro:hasPermission>
						<shiro:hasPermission name="qd:contract:view">
							<a href="${ctx}/qd/contract/detail?id=${contract.id}">查看</a>&nbsp;|&nbsp;
						</shiro:hasPermission>
						<shiro:hasPermission name="qd:contract:abort">
							<a href="${ctx}/qd/contract/abort?id=${contract.id}" onclick="return confirmx('确认要中止该合同吗？', this.href)">中止</a>
						</shiro:hasPermission>	
						</td>
						<td >${contract.paidAmount}</td>
						<td>${contract.code}</td>
						<td>${contract.amount}</td>
						<td> <fmt:formatDate value="${contract.limitDate}"  pattern="yyyy-MM-dd" /></td>
						<td><c:choose><c:when test="${contract.abort==0}"><c:choose><c:when test="${nowDate-contract.limitDate.time > 0}">已过期</c:when><c:otherwise>正常</c:otherwise></c:choose></c:when><c:otherwise>中止</c:otherwise></c:choose></td>
						<td><c:choose><c:when test="${contract.broken==0}">未断号</c:when><c:otherwise>断号</c:otherwise></c:choose></td>
						<td><c:choose><c:when test="${contract.status==0}">是</c:when><c:otherwise>否</c:otherwise></c:choose></td>
						<td>${contract.payHint}</td>
						<td>${contract.member.name}</td>
						<td>${contract.member.mobile}</td>
						<td>${contract.student.name}</td>
						<td><fmt:formatDate value="${contract.student.birthday}" pattern="yyyy-MM-dd" /></td>
						<td>${contract.sales.name}</td>
						<td>${contract.createBy.name}</td>
						<td ><fmt:formatDate value="${contract.createDate}"  pattern="yyyy-MM-dd" /></td>
						<td>${contract.updateBy.name}</td>
						<td ><fmt:formatDate value="${contract.updateDate}"  pattern="yyyy-MM-dd" /></td>
						<td> <c:choose><c:when test="${contract.isFree == 1}">是</c:when><c:otherwise>否</c:otherwise></c:choose></td>
					</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<!--/列表-->

		<!--内容底部-->
		<div class="line10"></div>
		<div class="pagelist">
			${page}
		</div>
		<!--/内容底部-->
	</body>
</html>
